#include <bits/stdc++.h>

using namespace std;
using ll = long long;

void solve()
{
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    ll ans = 0;
    for (int i = 0; i < n; i++) cin >> v[i], ans += v[i] * k;
    cout << ans << endl;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}